package org.lewis.demo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

@Api(tags = "演示请求")
@RequestMapping("demo")
@RestController
public class DemoController {

    private static final String format = "Hello, %s!";

    @ApiOperation("打招呼")
    @GetMapping("hello")
    public String sayHi(@RequestParam(defaultValue = "World") String name) {
        return String.format(format, name);
    }

    @PostMapping("now")
    public String now() {
        return LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
    }

}
